NetworkApi

interface NetworkApi

API for multi-loader abstraction of simple play-phase networking

See the Wiki for more details and examples.

Author

fzzyhmstrs

Since

0.4.1

Functions

Link copied to clipboard
abstract fun canSend(id: Identifier, playerEntity: PlayerEntity?): Boolean

Checks whether a certain channel can be used for sending a packet. Works in both networking directions.

Link copied to clipboard
abstract fun <T : CustomPayload> registerC2S(    id: CustomPayload.Id<T>,     codec: PacketCodec<in RegistryByteBuf, T>,     handler: C2SPayloadHandler<T>)

registers a server-bound (C2S) payload type and receipt handler. This must be done on both logical sides (client and server). A common entrypoint is typically the best place for this.

Link copied to clipboard
abstract fun <T : CustomPayload> registerLenientC2S(    id: CustomPayload.Id<T>,     codec: PacketCodec<in RegistryByteBuf, T>,     handler: C2SPayloadHandler<T>)

registers a server-bound (C2S) payload type and receipt handler. This does not have to be done on both server and client (hence lenient). This allows for clients without Fzzy Config to connect to a server with mods that register connections this way. A common entrypoint is typically the best place for this. * @param T the payload type to register

Link copied to clipboard
abstract fun <T : CustomPayload> registerLenientS2C(    id: CustomPayload.Id<T>,     codec: PacketCodec<in RegistryByteBuf, T>,     handler: S2CPayloadHandler<T>)

registers a client-bound (S2C) payload type and receipt handler. This does not have to be done on both server and client (hence lenient). This allows for clients without Fzzy Config to connect to a server with mods that register connections this way. A common entrypoint is typically the best place for registering this. * @param T the payload type to register

Link copied to clipboard
abstract fun <T : CustomPayload> registerS2C(    id: CustomPayload.Id<T>,     codec: PacketCodec<in RegistryByteBuf, T>,     handler: S2CPayloadHandler<T>)

registers a client-bound (S2C) payload type and receipt handler. This must be done on both logical sides (client and server). A common entrypoint is typically the best place for this.

Link copied to clipboard
abstract fun send(payload: CustomPayload, playerEntity: PlayerEntity?)

Sends a payload to a receiver. If the server player is defined, will be an S2C transmission, otherwise C2S